﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Lite.ExcelLibrary.BinaryDrawingFormat
{
    public partial class MsofbtBlipBitmapDIB : MsofbtBlip
    {
        public MsofbtBlipBitmapDIB(EscherRecord record) : base(record) { }

        public MsofbtBlipBitmapDIB()
        {
            this.Type = EscherRecordType.MsofbtBlipBitmapDIB;
        }

        public override void Decode()
        {
            MemoryStream stream = new MemoryStream(Data);
            BinaryReader reader = new BinaryReader(stream);
            this.UID = new Guid(reader.ReadBytes(16));
            this.Marker = reader.ReadByte();
            this.ImageData = reader.ReadBytes((int)(stream.Length - stream.Position));
        }

        public override void Encode()
        {
            MemoryStream stream = new MemoryStream();
            BinaryWriter writer = new BinaryWriter(stream);
            writer.Write(UID.ToByteArray());
            writer.Write(Marker);
            writer.Write(ImageData);
            this.Data = stream.ToArray();
            this.Size = (UInt32)Data.Length;
            base.Encode();
        }

    }
}
